/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package matematikapirma.sys;

import java.util.LinkedList;
import java.util.List;
import matematikapirma.Curve;
import matematikapirma.Point;
import matematikapirma.Surface;

/**
 *
 * @author Tadas
 */
public class SplinesSurface implements Surface {

    private Curve currentCurve;
    private boolean showDots = Surface.SHOW_DOTS;
    private boolean showLines = Surface.SHOW_LINES;
    private List<Curve> curves = new LinkedList<Curve>();
    private int steps = Surface.STEPS;
    private IntersectionEngine intersectionEngine;

    public SplinesSurface(IntersectionEngine intersectionEngine) {
        this.intersectionEngine = intersectionEngine;
    }

    public Curve getCurrentCurve() {
        return currentCurve;
    }

    public List<Curve> getCurves() {
        return curves;
    }

    public List<Point> getIntersectingPoints() {
        List<Point> intersecting = new LinkedList<Point>();

        for (int i = 0; i < curves.size() - 1; i++) {
            for (int j = i + 1; j < curves.size(); j++) {
                intersecting.addAll(intersectionEngine.getIntersectionPoints(curves.get(i), curves.get(j)));
            }
        }

        return intersecting;
    }

    public void addCurve(Curve curve) {
        curves.add(curve);
    }

    public void removeCurve(Curve curve) {
        curves.remove(curve);
    }

    public void setShowLines(boolean show) {
        showLines = show;
    }

    public boolean getShowLines() {
        return showLines;
    }

    public int getSteps() {
        return steps;
    }

    public void setSteps(int steps) {
        this.steps = steps;
        for(Curve curve : getCurves()){
            curve.updateCurve(null);
        }
    }

    public void setShowDots(boolean show) {
       showDots = show;
    }

    public boolean getShowDots() {
        return showDots;
    }

    public void setCurrentCurve(Curve curve) {
        this.currentCurve = curve;
    }
}
